package com.niodata.dp.log.viewer;

import java.io.IOException;

public class JschLogViewer implements LogViewer {


  @Override
  public ViewerSession tailFile(Host host, String file)
        throws IOException {
    String cmd = "tail -f " + file;
    JschViewerSession session = new JschViewerSession(host, cmd);
    return session;
  }

  @Override
  public ViewerSession tailFileLines(Host host, String file, int lineCount) throws IOException {
    String cmd = "tail -n " + lineCount + "  " + file;
    JschViewerSession session = new JschViewerSession(host, cmd);
    return session;
  }

  @Override
  public ViewerSession headFileLines(Host host, String file, int lineCount) throws IOException {
    String cmd = "head -n " + lineCount + "  " + file;
    JschViewerSession session = new JschViewerSession(host, cmd);
    return session;
  }

  @Override
  public ViewerSession grepFile(Host host, String file, String pattern)
        throws IOException {
    String cmd = "grep  " + pattern + "  " + file;
    JschViewerSession session = new JschViewerSession(host, cmd);
    return session;
  }
}
